package com.iflytek.cloud.thirdparty; import android.content.Context; import android.text.TextUtils; import com.facebook.ads.AudienceNetworkActivity; import com.iflytek.cloud.ErrorCode; import com.iflytek.cloud.RequestListener; import com.iflytek.cloud.SpeechConstant; import com.iflytek.cloud.SpeechError; import com.iflytek.cloud.SpeechUtility; import com.iflytek.cloud.thirdparty.L; import org.json.JSONObject; public class V extends AbstractC0276v { L.a a = new L.a() { /* class com.iflytek.cloud.thirdparty.V.AnonymousClass1 */ @Override // com.iflytek.cloud.thirdparty.L.a public void a(SpeechError speechError) { if (speechError != null) { O.c("upload error. please check net state:" + speechError.getErrorCode()); } else { O.a("upload succeed"); } if (V.this.h != null) { V.this.h.onCompleted(speechError); } } @Override // com.iflytek.cloud.thirdparty.L.a public void a(L l, byte[] bArr) { if (bArr != null) { try { String str = new String(bArr, AudienceNetworkActivity.WEBVIEW_ENCODING); O.a(str); int parseInt = Integer.parseInt(new JSONObject(str).getString(SpeechUtility.TAG_RESOURCE_RET)); if (parseInt != 0) { a(new SpeechError(parseInt, SpeechConstant.ENG_WFR)); return; } if (V.this.h != null) { P.a("GetNotifyResult", null); V.this.h.onBufferReceived(bArr); } a(null); } catch (Exception e) { a(new SpeechError((int) ErrorCode.ERROR_INVALID_RESULT)); } } } }; private String d = "http://openapi.openspeech.cn/webapi/wfr.do"; private String e = "pver=1.0"; private Context f = null; private L g = null; private RequestListener h; public V(Context context, R r) { this.c = r; this.f = context; this.g = new L(); } public int a(byte[] bArr, RequestListener requestListener) { try { this.h = requestListener; if (SpeechUtility.getUtility() == null) { return ErrorCode.MSP_ERROR_NOT_INIT; } String d2 = this.c.d("server_url"); if (TextUtils.isEmpty(d2)) { d2 = this.d; } String c = T.c(this.f, this.c); this.g.b(this.c.a("timeout", 20000)); this.g.a(1); this.g.a(d2, this.e, bArr, c); this.g.a(this.a); P.a("LastDataFlag", null); return 0; } catch (Exception e2) { return ErrorCode.ERROR_UNKNOWN; } } public void a() { this.g.a(); this.g = null; } @Override // com.iflytek.cloud.thirdparty.AbstractC0276v public boolean destroy() { return super.destroy(); } }